<?php
/**
 * Created by PhpStorm.
 * User: leo
 * Date: 2018/5/16
 * Time: 10:28
 */
header('Content-Type:application/json');
include '../classes/logincheck.php';
include '../classes/conn.php';
$id=$_POST['id'];
$sec=$_POST['sec'];
$sub=$_POST['sub'];
$class="";
if(islogin()=='stu_login') {
    $queryClass="select class from homework where Id='{$id}'";
    $res=mysql_query($queryClass);
    $row=mysql_fetch_assoc($res);
    $class=$row['class'];

    $querySec="select name from section where class='{$class}' and num='{$sec}'";
    $res=mysql_query($querySec);
    $row=mysql_fetch_assoc($res);
    $sec=$row['name'];

    if($sub!=0){
        $querySub="select name from subsection where num='{$sub}' and section='{$sec}'";
        $res=mysql_query($querySec);
        $row=mysql_fetch_assoc($res);
        $sub=$row['name'];
    }

    $data=array('sec'=>$sec,'sub'=>$sub);
    $data=json_encode($data);
    echo $data;
}
